package 非对称之美;

import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        char[] ch = in.next().toCharArray();
        int n = ch.length;
        boolean flag = false;
        for (int i = 1; i < n; i++) {
            if (ch[i] != ch[0]) {
                flag = true;
                break;
            }
        }
        if (!flag) {
            System.out.println(0);
        } else {
            if (check(ch, 0, n - 1)) {
                System.out.println(n - 1);
            } else {
                System.out.println(n);
            }
        }
    }

    private static boolean check(char[] ch, int i, int j) {
        while (i <= j) {
            if (ch[i] == ch[j]) {
                i++;
                j--;
            } else {
                break;
            }
        }
        return i > j;
    }
}
